<%--
  Created by IntelliJ IDEA.
  User: 19416
  Date: 2022-08-11
  Time: 15:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<form action="${pageContext.request.contextPath}/RoomInsetServlet" method="get">
    <p>
       机房名称： <input type="text" name="roomName" id="roomName">
    </p>
    <p>
       计算机数量： <input type="text" name="computerNumber" id="computerNumber">
    </p>
    <p>
       机房管理员： <input type="text" name="manager" id="manager">
    </p>
    <p>
        机房地址：<input type="text" name="location" id="location">
    </p>
    <p>
        机房状态：
        <select name="state" id="state">
            <option value="">==请选择==</option>
            <option value=1>使用中</option>
            <option value=2>休闲</option>
            <option value=3>维护</option>
        </select>
    </p>
    <p>
        <input type="submit" value="新增" id="btn">
    </p>
</form>
<script>
   $("#btn").click(function (){
       var roomName = $("#roomName").val();
       var computerNumber = $("#computerNumber").val();
       var state = document.getElementById("state");
       var reg = /([\u4E00-\u9FA5]|[A-Za-z])+/;//只要包含中文或者字母就提示

       if (roomName.length == 0){
           alert("机房名称不能为空！")
           return false;
       }else if (reg.test(computerNumber)){
           alert("计算机数量是大于0的整数")
           return false;
       }else if (state.value == ""){
           alert("请选择机房状态！")
           return false;
       }else {
           alert("添加成功！")
           return true;
       }



   })
</script>
</body>
</html>
